<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Class: Sass::Plugin::StalenessChecker</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (S)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span> &raquo; <span class='title'><a href="Plugin.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Plugin.html" title="Sass::Plugin (module)">Plugin</a></span>
     &raquo; 
    <span class="title">StalenessChecker</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/Plugin/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/Plugin/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/Plugin/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Sass::Plugin::StalenessChecker 
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Sass::Plugin::StalenessChecker</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/plugin/staleness_checker.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>The class handles <code>.s[ca]ss</code> file staleness checks via their mtime timestamps.</p>

<p>To speed things up two level of caches are employed:</p>

<ul>
<li>A class-level dependency cache which stores @import paths for each file. This is a long-lived cache that is reused by every StalenessChecker instance.</li>

<li>Three short-lived instance-level caches, one for file mtimes, one for whether a file is stale during this particular run. and one for the parse tree for a file. These are only used by a single StalenessChecker instance.</li>
</ul>

<p>Usage:</p>

<ul>
<li>For a one-off staleness check of a single <code>.s[ca]ss</code> file, the class-level <tt><a href="#stylesheet_needs_update%3F-class_method" title="Sass::Plugin::StalenessChecker.stylesheet_needs_update? (method)">stylesheet_needs_update?</a></tt> method should be used.</li>

<li>For a series of staleness checks (e.g. checking all files for staleness) a StalenessChecker instance should be created, and the instance-level <tt><a href="#stylesheet_needs_update%3F-instance_method" title="Sass::Plugin::StalenessChecker#stylesheet_needs_update? (method)">#stylesheet_needs_update?</a></tt> method should be used. the caches should make the whole process significantly faster. <em>WARNING</em>: It is important not to retain the instance for too long, as its instance-level caches are never explicitly expired.</li>
</ul>

  </div>
</div>
<div class="tags">
  
</div>


  <h2>Class Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#stylesheet_modified_since%3F-class_method" title="stylesheet_modified_since? (class method)">+ (Boolean) <strong>stylesheet_modified_since?</strong>(template_file, mtime, importer = nil) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether a Sass or SCSS stylesheet has been modified since a given time.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#stylesheet_needs_update%3F-class_method" title="stylesheet_needs_update? (class method)">+ (Boolean) <strong>stylesheet_needs_update?</strong>(css_file, template_file, importer = nil) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether or not a given CSS file is out of date and needs to be regenerated.</span>
  
</li>

    
  </ul>

  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (StalenessChecker) <strong>initialize</strong>(options) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  

  
    <span class="summary_desc">Creates a new StalenessChecker for checking the staleness of several stylesheets at once.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#stylesheet_modified_since%3F-instance_method" title="#stylesheet_modified_since? (instance method)">- (Boolean) <strong>stylesheet_modified_since?</strong>(template_file, mtime, importer = nil) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether a Sass or SCSS stylesheet has been modified since a given time.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#stylesheet_needs_update%3F-instance_method" title="#stylesheet_needs_update? (instance method)">- (Boolean) <strong>stylesheet_needs_update?</strong>(css_file, template_file, importer = nil) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether or not a given CSS file is out of date and needs to be regenerated.</span>
  
</li>

    
  </ul>
<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><a href="" title="Sass::Plugin::StalenessChecker (class)">StalenessChecker</a></tt>) <strong>initialize</strong>(options) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Creates a new StalenessChecker for checking the staleness of several stylesheets at once.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>{Symbol =&gt; Object}</tt>)</span>
      
      
        <span class='name'>options</span>
      
      
      
        &mdash;
        See <a href="file.SASS_REFERENCE.html#sass_options" tppabs="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#sass_options" title="the Sass options documentation">the Sass options documentation</a>.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


39
40
41
42
43
44
45
46
47
48
49
50
51</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/plugin/staleness_checker.rb', line 39</span>

def initialize(options)
  @dependencies = self.class.dependencies_cache

  # URIs that are being actively checked for staleness. Protects against
  # import loops.
  @actively_checking = Set.new

  # Entries in the following instance-level caches are never explicitly expired.
  # Instead they are supposed to automaticaly go out of scope when a series of staleness checks
  # (this instance of StalenessChecker was created for) is finished.
  @mtimes, @dependencies_stale, @parse_trees = {}, {}, {}
  @options = Sass::Engine.normalize_options(options)
end</pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="stylesheet_modified_since?-class_method">
  
    + (<tt>Boolean</tt>) <strong>stylesheet_modified_since?</strong>(template_file, mtime, importer = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether a Sass or SCSS stylesheet has been modified since a given time.</p>

<p>The distinction between this method and the instance-level <tt><a href="#stylesheet_modified_since%3F-instance_method" title="Sass::Plugin::StalenessChecker#stylesheet_modified_since? (method)">#stylesheet_modified_since?</a></tt> is that the instance method preserves mtime and stale-dependency caches, so it&#8217;s better to use when checking multiple stylesheets at once.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>template_file</span>
      
      
      
        &mdash;
        The location of the Sass or SCSS template.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>mtime</span>
      
      
      
        &mdash;
        The modification time to check against.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt><a href="Base-3.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Importers/Base.html" title="Sass::Importers::Base (class)">Sass::Importers::Base</a></tt>)</span>
      
      
        <span class='name'>importer</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        The importer used to locate the stylesheet. Defaults to the filesystem importer.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether the stylesheet has been modified.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


108
109
110</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/plugin/staleness_checker.rb', line 108</span>

def self.stylesheet_modified_since?(template_file, mtime, importer = nil)
  new(Plugin.engine_options).stylesheet_modified_since?(template_file, mtime, importer)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="stylesheet_needs_update?-class_method">
  
    + (<tt>Boolean</tt>) <strong>stylesheet_needs_update?</strong>(css_file, template_file, importer = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether or not a given CSS file is out of date and needs to be regenerated.</p>

<p>The distinction between this method and the instance-level <tt><a href="#stylesheet_needs_update%3F-instance_method" title="Sass::Plugin::StalenessChecker#stylesheet_needs_update? (method)">#stylesheet_needs_update?</a></tt> is that the instance method preserves mtime and stale-dependency caches, so it&#8217;s better to use when checking multiple stylesheets at once.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>css_file</span>
      
      
      
        &mdash;
        The location of the CSS file to check.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>template_file</span>
      
      
      
        &mdash;
        The location of the Sass or SCSS template that is compiled to <code>css_file</code>.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether the stylesheet needs to be updated.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


93
94
95</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/plugin/staleness_checker.rb', line 93</span>

def self.stylesheet_needs_update?(css_file, template_file, importer = nil)
  new(Plugin.engine_options).stylesheet_needs_update?(css_file, template_file, importer)
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="stylesheet_modified_since?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>stylesheet_modified_since?</strong>(template_file, mtime, importer = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether a Sass or SCSS stylesheet has been modified since a given time.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>template_file</span>
      
      
      
        &mdash;
        The location of the Sass or SCSS template.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>mtime</span>
      
      
      
        &mdash;
        The modification time to check against.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt><a href="Base-3.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Importers/Base.html" title="Sass::Importers::Base (class)">Sass::Importers::Base</a></tt>)</span>
      
      
        <span class='name'>importer</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        The importer used to locate the stylesheet. Defaults to the filesystem importer.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether the stylesheet has been modified.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


77
78
79
80</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/plugin/staleness_checker.rb', line 77</span>

def stylesheet_modified_since?(template_file, mtime, importer = nil)
  importer ||= @options[:filesystem_importer].new(".")
  dependency_updated?(mtime).call(template_file, importer)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="stylesheet_needs_update?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>stylesheet_needs_update?</strong>(css_file, template_file, importer = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether or not a given CSS file is out of date and needs to be regenerated.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>css_file</span>
      
      
      
        &mdash;
        The location of the CSS file to check.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>template_file</span>
      
      
      
        &mdash;
        The location of the Sass or SCSS template that is compiled to <code>css_file</code>.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether the stylesheet needs to be updated.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


60
61
62
63
64
65
66
67
68</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/plugin/staleness_checker.rb', line 60</span>

def stylesheet_needs_update?(css_file, template_file, importer = nil)
  template_file = File.expand_path(template_file)
  begin
    css_mtime = File.mtime(css_file)
  rescue Errno::ENOENT
    return true
  end
  stylesheet_modified_since?(template_file, css_mtime, importer)
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:40 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>